package com.ktjy.simple;

import com.ktjy.entity.AmericanCoffee;
import com.ktjy.entity.Coffee;
import com.ktjy.entity.LatteCoffee;

public class SimpleFactory {
    public static Coffee createCoffee(int num) throws Exception {
        Coffee coffee=null;
        if(num==1){
            coffee=new AmericanCoffee();
        }else if(num==2){
            coffee=new LatteCoffee();
        }else{
            throw new Exception("还没有这种咖啡");
        }
        return coffee;
    }
}
